package com.woniuxy.microaftersaleserver.reviewmag.mapper;

import com.github.pagehelper.PageInfo;
import com.woniuxy.microcommonserver.bean.aftersales_cyx.ReviewGoods;
import com.woniuxy.microcommonserver.pageHelper.PageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ReviewServiceMapper {

    /**
     * 添加评价记录
     * @param reviewGoods
     */
    @Options(
            useGeneratedKeys = true,
            keyProperty = "r.id"
    )
    @Insert("insert into review_goods " +
            "(gmt_create,goods_id,review_context,reply,service_id,gmt_modified,status,custom_id,is_deleted) " +
            "values (#{r.gmtCreate},#{r.goodsInfo.id},#{r.reviewContext},#{r.reply},#{r.customService.id},#{gmtModified},#{c.status},#{c.userInfo.id},0)")
    void addReviewService(@Param("r") ReviewGoods reviewGoods);

    /**
     * 删除评价记录
     * @param id
     */
    @Update("update review_goods set is_deleted =1 where id=#{id}")
    void deleteReviewService(int id);

    /**
     * 修改评论记录
     * @param reviewGoods
     */
    void updateReviewService(@Param("r") ReviewGoods reviewGoods);

    /**
     * 根据字段分页查询商品评论详情
     * @param reviewGoods
     * @return
     */
    List<ReviewGoods> findByParams(@Param("p") PageRequest request, @Param("r") ReviewGoods reviewGoods);
}
